﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 

namespace BackupMirthToTFS
{
    public partial class Dashboard : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindDashboardGrid();
            }
        }

        private void BindDashboardGrid()
        { 
            using (var db = new MirthBackupDataContext(Config.BackupMirthToTFSConnString))
            {
                MirthBackupGrid.DataSource = db.MirthBackups.ToList().OrderBy(x => x.Name).Select(x=>new {
                    Name = x.Name,
                    IsActive = (x.IsActive)?"Active":"Inactive",
                    LastCompletedOn = x.LastCompletedOn,
                    MirthHost = x.MirthHost
                });
                MirthBackupGrid.DataBind();                                
            }
        }
    }
}
